#include<iostream>
#include<algorithm>
using namespace std;
struct car{
    long long d;
    long long v;
    long long a;
}x[100050];
struct node{
    long long l;
    long long r;
}line[100050];
int id1[100050]={0};
int id2[100050]={0};
bool cmp1(int a,int b){
    return line[a].l<line[b].l||line[a].l==line[b].l&&a<b;
}
bool cmp2(int a,int b){
    return line[a].r<line[b].r||line[a].r==line[b].r&&a<b;
}
int topl=0;
long long pla[100050]={0};
long long maximum=0;
bool fl[100050]={0};
int ans=0;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    //cout<<"***"<<endl;
    int ttt;
    cin>>ttt;
    for(int sss=0;sss<ttt;sss++){
          //  cout<<sss<<endl;
        maximum=0;
        for(int i=0;i<100001;i++){
            x[i].d=0;
            x[i].v=0;
            x[i].a=0;
            line[i].l=0;
            line[i].r=0;
        }
        long long n,m,l,v;
        cin>>n>>m>>l>>v;
        for(int i=0;i<n;i++){
        //    cout<<i<<endl;
            cin>>x[i].d>>x[i].v>>x[i].a;
        }
        for(int i=0;i<m;i++){
      //      cout<<i<<i<<endl;
            cin>>pla[i];
            if(pla[i]>maximum)maximum=pla[i];
        }
    //cout<<"***"<<endl;
        for(int i=0;i<n;i++){
            if(x[i].a==0){
                if(x[i].d<=maximum&&x[i].v>v){
                    topl++;
                    int l=0;
                    int r=m-1;
                    while(l+1<r){
                        int mid=(l+r)/2;
                        if(pla[mid]<x[i].d)l=mid+1;
                        else r=mid;
                    }
                    if(pla[l]<x[i].d)l=r;
                    line[topl].l=l+1;
                    line[topl].r=m;
                }
            }
            if(x[i].a>0&&x[i].d<=maximum){
                if(x[i].v*x[i].v+2ll*x[i].a*(maximum-x[i].d)>v*v){
                    topl++;
                    int l=0;
                    int r=m-1;
                    int mid;
                    while(l+1<r){
                        mid=(l+r)/2;
                        if(pla[mid]<x[i].d)l=mid+1;
                        else r=mid;
                    }
                    if(pla[l]<x[i].d)l=r;
                    r=m-1;
                    while(l+1<r){
                        mid=(l+r)/2;
                        if(x[i].v*x[i].v+2ll*x[i].a*(pla[mid]-x[i].d)>v*v)r=mid;
                        else l=mid+1;
                    }
                    if(x[i].v*x[i].v+2ll*x[i].a*(pla[l]-x[i].d)<=v*v)l=r;
                    line[topl].l=l+1;
                    line[topl].r=m;
                }
            }
            if(x[i].a<0&&x[i].d<=maximum){
                int ll=0;
                int rr=m-1;
                int mid;
                while(ll+1<rr){
                    mid=(ll+rr)/2;
                    if(pla[mid]<x[i].d)ll=mid+1;
                    else rr=mid;
                }
                if(pla[ll]<x[i].d)ll=rr;
                if(x[i].v*x[i].v+2ll*x[i].a*(pla[ll]-x[i].d)>v*v){
                    topl++;
                    int l=ll;
                    int r=m-1;
                    while(l+1<r){
                        mid=(l+r)/2;
                        if(x[i].v*x[i].v+2ll*x[i].a*(pla[mid]-x[i].d)>v*v)l=mid;
                        else r=mid-1;
                    }
                    if(x[i].v*x[i].v+2ll*x[i].a*(pla[r]-x[i].d)<=v*v)r=l;
                    line[topl].l=ll+1;
                    line[topl].r=r+1;
                }
            }
            //cout<<topl<<endl;
        }
        for(int i=0;i<=topl;i++){
            id1[i]=i;
            id2[i]=i;
        }
        cout<<topl<<" ";
        if(topl==0){
            cout<<m<<endl;
            continue;
        }
        sort(id1+1,id1+topl+1,cmp1);
        sort(id2+1,id2+topl+1,cmp2);
        for(int i=0;i<=100001;i++)fl[i]=0;
        int p=1;
        ans=0;
        for(int i=1;i<=topl;i++){
              //  cout<<i<<" "<<id2[i]<<endl;
            if(fl[id2[i]]==0){
                fl[id2[i]]=1;
                ans++;
                //cout<<line[id2[i]].r<<" "<<i<<endl;
                while(p<=topl&&line[id1[p]].l<=line[id2[i]].r){
                    fl[id1[p]]=1;
                    p++;
                }
            }
        }
        cout<<m-ans<<endl;
        //for(int i=1;i<=topl;i++){
            //cout<<line[i].l<<" "<<line[i].r<<" "<<"***"<<endl;
       // }
        topl=0;
    }
    return 0;
}
